<?php
/**
 * Created by singwa
 * User: singwa
 * motto: 现在的努力是为了小时候吹过的牛逼！
 * Time: 23:37
 */

use think\facade\Route;

//不要使用分组路由,限制太多
//ProductController
if (true) {
    Route::post(':version/product', ':version.ProductController/createOne');
    Route::delete(':version/product/:id', ':version.ProductController/deleteOne');
    Route::get(':version/product/by_category/paginate', ':version.ProductController/getByCategory');
    Route::get(':version/product/by_category', ':version.ProductController/getAllInCategory');
    Route::get(':version/product/:id', ':version.ProductController/getOne')->pattern(['id' => '\d+']);
    Route::get(':version/product/recent', ':version.ProductController/getRecent');
}

//Token
if (true) {
    Route::post(':version/token/user', ':version.TokenController/getToken');
    Route::post(':version/token/app', ':version.TokenController/getAppToken');
    Route::post(':version/token/verify', ':version.TokenController/verifyToken');
}

//Banner
Route::get(':version/banner/:id', ':version.BannerController/getBanner')->pattern(['id' => '\d+']);
//Sample
Route::get(':version/sample/:key', ':version.Sample/getSample');
Route::post(':version/sample/test3', ':version.Sample/test3');

if (true) {

//Miss 404
//Miss 路由开启后，默认的普通模式也将无法访问
//Route::miss('v1.Miss/miss');

//Theme
// 如果要使用分组路由，建议使用闭包的方式，数组的方式不允许有同名的key
    Route::get(':version/theme', ':version.ThemeController/getSimpleList');
    Route::get(':version/theme/:id', ':version.ThemeController/getComplexOne')->pattern(['id' => '\d+']);
    Route::post(':version/theme:t_id/product/:p_id', ':version.ThemeController/addThemeProduct');
    Route::delete(':version/theme:t_id/product/:p_id', ':version.ThemeController/deleteThemeProduct');
//Category
    Route::get(':version/category', ':version.CategoryController/getCategories');
    Route::get(':version/category/all', ':version.CategoryController/getAllCategories');


//Address
    Route::post(':version/address', ':version.AddressController/createOrUpdateAddress');
    Route::get(':version/address', ':version.AddressController/getUserAddress');

}
//Order
if (true) {

    Route::post(':version/order', ':version.OrderController/placeOrder');
    Route::get(':version/order/:id', ':version.OrderController/getDetail')->pattern(['id' => '\d+']);
    Route::put(':version/order/delivery', ':version.OrderController/delivery');
    Route::get(':version/order/paginate', ':version.OrderController/getSummary');
//不想把所有查询都写在一起，所以增加by_user，很好的REST与RESTFul的区别
    Route::get(':version/order/by_user', ':version.OrderController/getSummaryByUser');
}


//Pay
Route::post(':version/pay/pre_order', ':version.PayController/getPreOrder');
Route::post(':version/pay/notify', ':version.PayController/receiveNotify');
Route::post(':version/pay/re_notify', ':version.PayController/redirectNotify');
Route::post(':version/pay/concurrency', ':version.PayController/notifyConcurrency');

//Message
Route::post(':version/message/delivery', ':version.MessageController/sendDeliveryMsg');




